#encoding=utf-8
__author__ = 'Soul'

'''
    url: http://www.i-ev.com/index.php?m=content&c=index&a=lists&catid=124
'''
from core.PageFetcher import *
class IEvPageFetcher(PageFetcher):
    def __init__(self):
        pass

    def analysis(self):
        from lxml.html import fromstring

        parsed_html = fromstring(self.__html_src__)

        new_cars = parsed_html.xpath("//div[@class='layout']/ul[@class='n-car']/li")
        for i in range(0, len(new_cars)):
            new_car = new_cars[i]
            next_url = new_car.xpath('/a/@href')

            logger.info("append %s to urls_to_visit" % (next_url))
            if self.__mutex__.acquire(1):
                urls_to_visit.append(next_url)
                self.__mutex__.release()
